<%--
  Created by IntelliJ IDEA.
  User: 星星在唱歌
  Date: 2022/2/17
  Time: 17:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    img{
      /*表示显示手型*/
      cursor:pointer;
    }
  </style>
</head>
<body>
<h1>用户登录</h1>
<form action="<%=request.getContextPath()%>/login" method="post">
  <table border="1" cellspacing="0" cellpadding="10" width="40%">
    <tr>
      <td>用户名</td>
      <td>
        <input type="text" name="username" id="username">
      </td>
    </tr>
    <tr>
      <td>密码</td>
      <td>
        <input type="password" name="userpwd" id="userpwd">
      </td>
    </tr>
    <tr>
      <td>验证码：</td>
      <td>
          <input type="text" name="loginCode" id="">
          <img src="<%=request.getContextPath()%>/checkcode" id="im" onclick="refresh()">
          <br>
          <%--提示信息--%>
          <span style="color: red"><%=request.getAttribute("msg")%></span>
      </td>
    </tr>
    <tr>
      <td colspan="2" align="center">
        <input type="submit" value="登录">
      </td>
    </tr>
  </table>
</form>
<br><br>
小老板，还没注册？<a href="<%=request.getContextPath()%>/register.jsp">立即注册</a>

<script>
  function refresh(){
    let img = document.getElementById("im");
    var date = new Date();
    img.src = "<%=request.getContextPath()%>/checkcode?date="+date.getTime();
  }
</script>

<%
  //设置弹框
  String msg = request.getParameter("msg");
  if(msg != null && msg.equals("error")){

%>
  <script>
    alert("用户登录失败！");
  </script>
<%
  }
%>
</body>
</html>
